#include <iostream>
#include <stdlib.h>

using namespace std;

#define INITSIZE 10

//动态分配
typedef struct {
    int *data;
    int MaxSize;
    int length;
}SqList_dynamic;

void initList_dynamic(SqList_dynamic &L);
void increaseSize_dynamic(SqList_dynamic &L,int len);
void show(SqList_dynamic L);

int main(){
    SqList_dynamic L;
    initList_dynamic(L);
    show(L);
    increaseSize_dynamic(L,10);
    show(L);



    return 0;

}


void initList_dynamic(SqList_dynamic &L){
    L.data=(int *)malloc(sizeof(int) * INITSIZE );
    L.length=0;
    L.MaxSize=INITSIZE;
}
void increaseSize_dynamic(SqList_dynamic &L,int len){
    int *p=L.data;
    L.data=(int *)malloc(sizeof(int)*(L.MaxSize+len));
    for (int i = 0; i < L.length; ++i) {
        L.data[i]=p[i];
    }
    L.MaxSize=L.MaxSize+len;
    free(p);
}
void show(SqList_dynamic L){
    for (int i = 0; i < L.MaxSize; ++i) {
        cout<<L.data[i]<<"  ";
    }
    cout<<endl;
}

